#!/bin/bash
#-----------------------------------------------------------------------------
#   arcasHLA: high resolution HLA typing from RNA seq
#-----------------------------------------------------------------------------
#
#   Authors:    Rose Orenbuch, Ioan Filip, Itsik Pe'er
#   Date:       2019-06-26
#   Version:    0.2.0
#   License:    GNU
#
#-----------------------------------------------------------------------------
#   
#   arcasHLA types high resolution HLA alleles from BAM.
#
#-----------------------------------------------------------------------------
#   Requirements
#-----------------------------------------------------------------------------

if [ ! -x "$(command -v kallisto pseudo)" ]; then
    echo "Warning: missing dependency - Kallisto v0.44.0"
fi

if [ ! -x "$(command -v samtools)" ]; then
    echo "Warning: missing dependency - Samtools"
fi

if [ ! -x "$(command -v bedtools)" ]; then
    echo "Warning: missing dependency - bedtools"
fi

if [ ! -x "$(command -v pigz)" ]; then
    echo "Warning: missing dependency - pigz"
fi

if [ ! -x "$(command -v python3 -c "import numpy")" ]; then
    echo "Warning: missing dependency - python3 module NumPy"
fi

if [ ! -x "$(command -v python3 -c "import pandas")" ]; then
    echo "Warning: missing dependency - python3 module pandas"
fi

if [ ! -x "$(command -v python3 -c "import Bio")" ]; then
    echo "Warning: missing dependency - python3 module Biopython"
fi

#-----------------------------------------------------------------------------
#   Tools
#-----------------------------------------------------------------------------

ARCASHLA_ROOT_DIR=$(realpath $(dirname $0))

if [ "$1" == "extract" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/extract.py ${@:2}

elif [ "$1" == "genotype" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/genotype.py ${@:2}

elif [ "$1" == "merge" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/merge.py ${@:2}

elif [ "$1" == "reference" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/reference.py ${@:2}

elif [ "$1" == "partial" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/partial.py ${@:2}
    
elif [ "$1" == "customize" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/customize.py ${@:2}

elif [ "$1" == "quant" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/quant.py ${@:2}

elif [ "$1" == "convert" ]; then

    python3 ${ARCASHLA_ROOT_DIR}/scripts/convert.py ${@:2}
    
#-----------------------------------------------------------------------------
#   Usage
#-----------------------------------------------------------------------------

else
    echo "Usage: arcasHLA <command> [options]"
    echo
    echo "    extract        extracts chromosome 6 reads from bam"
    echo "    genotype       types HLA genes from extracted reads"
    echo "    partial        types partial HLA genes from extracted reads"
    echo
    echo "    customize      create custom HLA reference"
    echo "    quant          allele specific HLA quantification"
    echo
    echo "    merge          processes results into a tab-separated table"
    echo "    convert        converts HLA nomenclature/resolution"
    echo "    reference      check or update HLA reference"
    echo 
    echo "Note: run any command with --help to view required fields, options"
    echo
fi
#-------------------------------------------------------------------------------
